/*
 * NetworkManager.java
 *    Author: nfk
 *      Date: Sep 19, 2008
 *      
 *   I'faces:
 *      NetworkManager
 */

package at.momberban.game.me;


import java.io.IOException;


/**
 * An basic interface for network managers.
 * @author nfk
 */
public interface NetworkManager {

    /**
     * Forces the client/server to drop all connections (and possibly shutdown listeners).
     */
    public void disconnect();


    /**
     * Sends specified string to the output stream(s).
     * @param s the string to send
     * @throws NullPointerException if s is null
     * @throws IOException if any network error occurs
     * @throws IllegalStateException if no output stream is available
     */
    public void send(final String s) throws IOException;


    /**
     * Receives a new line on the input stream(s).
     * @return the new line
     * @throws IOException if any network error occurs
     * @throws IllegalStateException if no input stream is available
     */
    public String receive() throws IOException;


    /**
     * Specifies the event listener which handles incoming strings.
     * @param listener the event listener
     * @throws NullPointerException if listener is null
     */
    public void setEventListener(final EventGenerator listener);

}

/* End of NetworkManager.java */
